<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>判断一个数是否是素数</title>
</head>
<body>
<script>
    function isZhiShu(n) {
        if (n < 2) {
            return false;
        }
        for (var i = 2; i <= Math.sqrt(n); i++) {
            if (n % i === 0) {
                return false;
            }
        }
        return true;
    }

    alert("9: " + isZhiShu(9));
    alert("7: " + isZhiShu(7));
</script>
</body>
</html>